package com.malbbmsomanager.retailmanagement;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import com.malbbmsomanager.reports.DM_BBM_Customer_Last_Three_Visit;
import com.malbbmsomanagerdemo.DM_BBM_InvoiceMenu;
import com.malbbmsomanagerdemo.R;

import android.app.ActionBar;
import android.app.TabActivity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TabHost;
import android.widget.Toast;
import android.widget.TabHost.TabSpec;

public class DM_BBM_Retailer_Info_Main_Tabs extends TabActivity implements
ActionBar.OnNavigationListener{
	private static final String TAG = null;
	String TagIdRetailer;
	// action bar
	private ActionBar actionBar;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dm_bbm_retailer_info_main_tabs);
	
		actionBar = getActionBar();

		// Hide the action bar title
		actionBar.setDisplayShowTitleEnabled(true);
		actionBar.setDisplayHomeAsUpEnabled(false);
		
		
		TabHost tabHost = getTabHost();

		// Tab for Display accounts
		TabSpec retInfo = tabHost.newTabSpec("Retailer");
		retInfo.setIndicator("Retailer", getResources()
				.getDrawable(R.drawable.exit));
		Intent photosIntent = new Intent(this, DM_BBM_Retailer_Information.class);
		retInfo.setContent(photosIntent);

		// Tab for add new account
		TabSpec merchInfo = tabHost.newTabSpec("Merchant");
		// setting Title and Icon for the Tab
		merchInfo.setIndicator("Merchant",
				getResources().getDrawable(R.drawable.exit));
		Intent songsIntent = new Intent(this,
				DM_BBM_Merchandising_Information.class);
		merchInfo.setContent(songsIntent);

		// Tab for display accounts reports
		TabSpec retoutInfo = tabHost.newTabSpec("Outstand");
		retoutInfo.setIndicator("Outstand",
				getResources().getDrawable(R.drawable.exit));
		Intent videosIntent = new Intent(this,
				DM_BBM_RetOutstanding_Information.class);
		videosIntent.putExtra("TAGID", "TAB/0000");
		retoutInfo.setContent(videosIntent);

		// Adding all TabSpec to TabHost
		tabHost.addTab(retInfo); // Display Retailer Information tab
		//tabHost.addTab(merchInfo); // Display Merchandising Information tab
		tabHost.addTab(retoutInfo); // Display Outstanding Information tab
	}
	@Override
	public void onBackPressed() {
		// Do Here what ever you want do on back press;
		
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.action_search:
			// search action
			return true;
		case R.id.action_location_found:
			// location found
			LocationFound();
			return true;
		case R.id.action_refresh:
			// refresh
			/*
			 * refreshMenuItem = item; // load the data from server new
			 * SyncData().execute();
			 */
			return true;
		case R.id.action_help:
			// help action
			return true;
		case R.id.action_check_updates:
			// check for updates action
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	private void LocationFound() {
		// TODO Auto-generated method stub
		Intent i = new Intent(DM_BBM_Retailer_Info_Main_Tabs.this,
				DM_BBM_Retailer_Master.class);
		i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
				| Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(i);
		finish();
		return;
	}

	@Override
	public boolean onNavigationItemSelected(int itemPosition, long itemId) {
		// TODO Auto-generated method stub
		return false;
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main_actions, menu);
		return true;
	}
}
